package com.lglbc.mybatispluslearning.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lglbc.mybatispluslearning.entity.MallOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 乐哥聊编程
 * @description mall_orderMapper
 * @date 2022-07-17
 */
@Mapper
public interface MallOrderMapper extends BaseMapper<MallOrder> {

    @Select(
            "<script>select t0.* from mall_order t0 " +
                    //add here if need left join
                    "where 1=1" +
                    "<when test='id!=null and id!=&apos;&apos; '> and t0.id=#{id}</when> " +
                    "<when test='name!=null and name!=&apos;&apos; '> and t0.name=#{name}</when> " +
                    "<when test='mobile!=null and mobile!=&apos;&apos; '> and t0.mobile=#{mobile}</when> " +
                    "<when test='address!=null and address!=&apos;&apos; '> and t0.address=#{address}</when> " +
                    "<when test='orderStatus!=null and orderStatus!=&apos;&apos; '> and t0.order_status=#{orderStatus}</when> " +
                    //add here if need page limit
                    //" limit ${page},${limit} " +
                    " </script>")
    List<MallOrder> pageAll(MallOrder queryParamDTO, int page, int limit);

    @Select("<script>select count(1) from mall_order t0 " +
            //add here if need left join
            "where 1=1" +
            "<when test='id!=null and id!=&apos;&apos; '> and t0.id=#{id}</when> " +
            "<when test='name!=null and name!=&apos;&apos; '> and t0.name=#{name}</when> " +
            "<when test='mobile!=null and mobile!=&apos;&apos; '> and t0.mobile=#{mobile}</when> " +
            "<when test='address!=null and address!=&apos;&apos; '> and t0.address=#{address}</when> " +
            "<when test='orderStatus!=null and orderStatus!=&apos;&apos; '> and t0.order_status=#{orderStatus}</when> " +
            " </script>")
    int countAll(MallOrder queryParamDTO);

}